//
//  WATFScanView.swift
//  WiFiFaster
//
//  Created by one on 2023/12/28.
//

import UIKit

class WATFScanView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(watf_scanBgImgView)
        addSubview(watf_scanImgView)
        addSubview(watf_scanAnimateImgView)
        addSubview(watf_scanLabel)
        watf_scanBgImgView.snp.makeConstraints { make in
            make.size.equalTo(261)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview()
        }
        watf_scanAnimateImgView.snp.makeConstraints { make in
            make.size.equalTo(261)
            make.centerX.centerY.equalTo(watf_scanBgImgView)
        }
        watf_scanImgView.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 39, height: 33))
            make.centerX.centerY.equalTo(watf_scanBgImgView)
        }
        watf_scanLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(watf_scanBgImgView.snp.bottom).offset(38)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //MARK: - watf lazy
    lazy var watf_scanImgView: UIImageView = {
        let watf_scanImgView = UIImageView(image: UIImage(named: "watf_scan_speed"))
        return watf_scanImgView
    }()
    lazy var watf_scanBgImgView: UIImageView = {
        let watf_scanBgImgView = UIImageView(image: UIImage(named: "watf_scan_speedBg"))
        return watf_scanBgImgView
    }()
    lazy var watf_scanAnimateImgView: UIImageView = {
        let watf_scanAnimateImgView = UIImageView(image: UIImage(named: "watf_scan_animate"))
        watf_scanAnimateImgView.layer.add(watf_scanKey, forKey: "watf_scanKey")
        return watf_scanAnimateImgView
    }()
    lazy var watf_scanKey: CABasicAnimation = {
        let watf_scanKey = CABasicAnimation.init(keyPath: "transform.rotation")
        watf_scanKey.fromValue = NSNumber.init(value: 0)
        watf_scanKey.toValue = NSNumber.init(value: Double.pi*2)
        watf_scanKey.duration = 1
        watf_scanKey.repeatCount = MAXFLOAT
        watf_scanKey.isRemovedOnCompletion = false
        return watf_scanKey
    }()
    lazy var watf_scanLabel: UILabel = {
        let watf_scanLabel =  UILabel()
        watf_scanLabel.textColor = .white
        watf_scanLabel.font = UIFont.systemFont(ofSize: 16)
        watf_scanLabel.text = "Testing..."
        return watf_scanLabel
    }()
}
